/*
 * Copyright 2009 Brook Smith brook.smith@paradise.net.nz.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.javagenerate.generator;

public class NamingUtils {

	public static String getPackageName(String className) {
		return className.substring(0, className.lastIndexOf("."));
	}

	public static String getSimpleName(String className) {
		return className.substring(className.lastIndexOf(".") + 1);
	}
	
	public static String getMethodShortName(String name) {
		return name.replaceFirst("(get|set|is|has)", "");
	}

	public static String upperFirst(String name) {
		return String.valueOf(name.charAt(0)).toUpperCase() + name.substring(1);
	}

	public static String lowerFirst(String name) {
		return String.valueOf(name.charAt(0)).toLowerCase() + name.substring(1);
	}

	
	public static void main(String[] args) {
		String blah = "com.test.generator.Classname";
		System.out.println(getSimpleName(blah));
		System.out.println(getPackageName(blah));
		
		System.out.println(getMethodShortName("getName"));
		System.out.println(getMethodShortName("setName"));
	}
}
